import pageination from '../../components/pageination/pageination.vue'
export default {
	data() {
			return {
				userData: [],
				//数据
				total: 0, //总条数
				page: 1, //当前页
				size: 10, //每页显示条数
        search: '',
        unaudit: '',
				auditModelShow:false,//审核弹框是否显示
				auditStatus:1,//评审结果
				auditDetailModelShow:false,//审核详情弹框是否显示
        article: {},
        articleList: [] //话题信息
			}
		},
		components: {
			pageination
		},
		created() { //调用方法
			let that = this;

		},
		mounted() {},
		methods: { //写函数方法

			getData: function() {
				let that = this;
				that.$post(
						that.urls.queryArticle, {
							"type": 1,
              "topicSearch": that.search,
              "unaudit": that.unaudit,
						  "pageNum": that.page,
							"pageSize": that.size
						}
					)
					.then(function(res) {
						if (res.success) {
							that.articleList = res.pageInfo.list;
							that.page = res.pageInfo.pageNum;
							that.total = res.pageInfo.total;
						}
					})
			},
			//页码切换执行方法
			pageFn: function(val, pid) {
				this.page = parseInt(val);
				this.getData();
				//此处调列表数据接口
				//	this.searchTodo(pid); //查询新闻
			},
			/**返回子组件用户选择的一页显示条数**/
			obtainChild: function(data) {
				this.row = data;
			},

			toDateStr(timestamp) {
				let time = new Date(timestamp) // 先将时间戳转为Date对象，然后才能使用Date的方法
				let year = time.getFullYear(),
					month = time.getMonth() + 1, // 月份是从0开始的
					day = time.getDate();
				//  hour = time.getHours(),
				//  minute = time.getMinutes(),
				//  second = time.getSeconds();
				//  return year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
				return year + '-' + month + '-' + day;
			},
			searchUser: function() {
				let that = this;
				let value = $('#searchUserVal').val();
				that.$post(
						that.urls.findAllUser, {
							"pageNum": that.page,
							"pageSize": that.size,
							userName: value
								//	"userPhoneNumber": parseInt(value),
						}
					)
					.then(function(res) {
						if (res.success) {
							that.userData = res.pageInfo.list;
							that.page = res.pageInfo.pageNum;
							that.total = res.pageInfo.total;
						}
					})
			},
			/*审核*/
			audit:function(article){
				let articleTemp = {};
        articleTemp.id = article.id;
        articleTemp.auditStatus = 1;
        articleTemp.auditMsg = "";
			  this.article = articleTemp;
			  this.auditModelShow=true;
			},
			/*审核详情*/
			auditDetail:function(article){
				this.article = article;
			  this.auditDetailModelShow=true;
			},
			/*关闭弹框*/
			closeModel:function(){
				this.auditModelShow=false;
				this.auditDetailModelShow=false;
			},
      //审核话题
      auditTopic: function() {
			  let that = this;
			  if (that.article.id == null || that.article.auditMsg.length > 100) {
			  	layer.alert("审核意见100字以内！！");
			    return;
        }
        that.$post(
          that.urls.auditArticle,
          that.article
        )
        .then(function(res) {
          let msg = "";
          if(res.success) {
            msg = '审核成功！';
            //重新渲染数据
            that.getData();
            that.closeModel();
          } else {
            msg = '审核失败！';
          }
          layer.msg(msg, {
            time: 3000, //3s后自动关闭
          });
        })

      },
			/*跳转到话题详情页面*/
			topicDetail:function(id){
				if (id == null) {
				  return;
        }
        this.set("topicDetailid", id);
			  this.$router.push({
					path: "/topicDetail",
				})
			},
		}
}
